<template>
    <view class="custom-tag-popup" v-if="show">
        <view class="mask" @tap="cancel"></view>
        <view class="content">
            <view class="title">自定义标签</view>
            <input 
                type="text" 
                v-model="inputValue" 
                placeholder="最多4个字"
                maxlength="4"
                class="tag-input"
            />
            <view class="actions">
                <text class="cancel-btn" @tap="cancel">取消</text>
                <text class="confirm-btn" @tap="confirm">确定</text>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    name: 'custom-tag-input',
    props: {
        show: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            inputValue: ''
        }
    },
    methods: {
        cancel() {
            this.inputValue = ''
            this.$emit('update:show', false)
        },
        confirm() {
            if (!this.inputValue.trim()) {
                return
            }
            this.$emit('confirm', this.inputValue.trim())
            this.inputValue = ''
            this.$emit('update:show', false)
        }
    }
}
</script>

<style lang="scss" scoped>
.custom-tag-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;

    .mask {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
    }

    .content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 600rpx;
        background: #fff;
        border-radius: 20rpx;
        padding: 40rpx;

        .title {
            text-align: center;
            font-size: 32rpx;
            font-weight: bold;
            margin-bottom: 40rpx;
        }

        .tag-input {
            width: 100%;
            height: 80rpx;
            border: 1px solid #eee;
            border-radius: 8rpx;
            padding: 0 20rpx;
            margin-bottom: 40rpx;
            text-align: center;
        }

        .actions {
            display: flex;
            justify-content: space-between;
            padding: 0 40rpx;

            text {
                font-size: 32rpx;
                padding: 20rpx 40rpx;

                &.cancel-btn {
                    color: #666;
                }

                &.confirm-btn {
                    color: #ff6b6b;
                }
            }
        }
    }
}
</style> 